<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta property="og:title" content="" /> 
        <meta property="og:description" content="" /> 
        <meta name="keywords" content=""/>
        <title>Mens Biore</title>
        <script type="text/javascript" src="<?= PATH_URL . 'static/js/' ?>jquery-1.8.1.min.js"></script>
        <script type="text/javascript" src="<?= PATH_URL; ?>static/js/admin/jquery.url.js"></script>
        <script type="text/javascript">
            var root= '<?= PATH_URL ?>';
        </script>

        <?php
        if ($type == 'google') {
            ?>
            <script type="text/javascript">
                var url ='<?= PATH_URL . 'users/getProfile_google/' ?>'+$.url().fparam('access_token');
                $.ajax({
                    type: "POST",
                    url:url,
                    success: function(data) {
                        if(data=='SUCCESS'){
                            window.opener.fbLogin();
                            window.close();
                        }else{
                            window.location=root+"#/Account/Login";
                            return false;
                        }
                    }
                });
                        
            </script>
            <?php
        } else if ($type == 'yahoo') {
            ?>
            <script type="text/javascript">
                var url='<?= PATH_URL . 'users/getProfile_yahoo?' ?>'+$.url().attr('query'); 
                $.ajax({
                    type: "POST",
                    url: url,
                    success: function(data) {
                        if(data=='SUCCESS'){
                            window.opener.fbLogin();
                            window.close();
                        }else{
                            window.location=root+"#/Account/Login";
                            return false;
                        }
                    }
                });
            </script>
            <?php
        } else {
            ?>
            <script type="text/javascript">
                $(function() {
                    queryString = $.url(window.location).attr('fragment');
                    if(queryString!='' && $.url(window.location).fparam('state')){
                        $.getJSON(root+'users/LoginOpenId?'+queryString,function(data){
                            //console.log(data);
                            if(data.st=='SUCCESS'){
                                window.opener.fbLogin();
                                window.close();
                            }
                        });
                    }else{
                        $.getJSON(root+'users/LoginOpenId/fb?'+queryString, function(data) {
                            if(data.st=='SUCCESS'){
                                try
                                {
                                    window.opener.fbLogin();
                                    window.close();
                                }
                                catch(err)
                                {
                                    //window.close();
                                    window.location=root+"#/Account/Login";
                                    return false;
                                }
                            }	
                        });
                    }
                });
            </script>
            <?php
        }
        ?>
    </head>

    <body>
        <p> Đang xử lý...</p>
        <div id="content_getProfile"></div>
    </body>
</html>